
Page({
  data: {
    address: '',
    selectIndex: '',
    description: [],
    list: [
      {
        name: '中餐',
        id: 0,
        ch: false
      },
      {
        name: '西餐',
        id: 1,
        ch: false
      },
      {
        name: '面食',
        id: 2,
        ch: false
      },
      {
        name: '熨烫',
        id: 3,
        ch: false
      },
      {
        name: '驾驶',
        id: 4,
        ch: false
      },
      {
        name: '园艺',
        id: 5,
        ch: false
      },
      {
        name: '家教',
        id: 6,
        ch: false
      },
      {
        name: '营养',
        id: 7,
        ch: false
      },
      {
        name: '月子餐',
        id: 8,
        ch: false
      },
    ],
    selectIndex2: '',
    workTime: '',
    list2: [
      {
        name: '全天白板',
        id: 0
      },
      {
        name: '均可',
        id: 1
      },
      {
        name: '住家',
        id: 2
      },
      {
        name: '上午白班',
        id: 3
      },
      {
        name: '下午白班',
        id: 4
      },
      {
        name: '钟点',
        id: 5
      },
    ],
    selectIndex3: '',
    education: '',
    list3: [
      {
        name: '小学',
        id: 0
      },
      {
        name: '初中',
        id: 1
      },
      {
        name: '中专',
        id: 2
      },
      {
        name: '职高',
        id: 3
      },
      {
        name: '高中',
        id: 4
      },
      {
        name: '专科',
        id: 5
      },
      {
        name: '本科',
        id: 6
      },
      {
        name: '研究生及以上',
        id: 7
      },

    ]
  },
  clickItem(e) {
    const data = e.currentTarget.dataset;
    let ch = data.item.ch ? false : true;
    let list = this.data.list;
    list.forEach(item => {
      if (item.id == data.item.id) {
        item.ch = ch
      }
    })
    this.setData({
      list: list
    })
  },
  clickItem2(e) {
    console.log(e)
    const data = e.currentTarget.dataset;
    this.setData({
      selectIndex2: data.index,
      workTime: data.item.name
    })
  },
  clickItem3(e) {
    console.log(e)
    const data = e.currentTarget.dataset;
    this.setData({
      selectIndex3: data.index,
      education: data.item.name
    })
  },
  doNext() {
    let data = this.data, description = [];
    data.list.forEach(item => {
      if (item.ch) {
        description.push(item.name)
      }
    });
    if (description.length == 0) {
      wx.showModal({
        title: '温馨提示',
        content: '擅长工作内容不能为空！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
      return
    }
  
    if (data.workTime === ''||data.workTime == null) {
      wx.showModal({
        title: '温馨提示',
        content: '接什么样的单不能为空！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
      return
    }
  
    if (data.address === ''||data.address == null) {
      wx.showModal({
        title: '温馨提示',
        content: '住址不能为空！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
      return
    }
  
    if (data.education === ''||data.education == null) {
      wx.showModal({
        title: '温馨提示',
        content: '学历不能为空！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
      return
    }
    try {
      let storageData = wx.getStorageSync('bmhetong');
      storageData.description = description.join();
      storageData.workTime = data.workTime;
      storageData.address = data.address;
      storageData.education = data.education;
      console.log(storageData);
      wx.setStorageSync('bmhetong', storageData);
      wx.navigateTo({ url: '/page5/bmhetong3/index' })
    } catch (e) { }

  },
  doBack() {
    wx.navigateBack({
      delta: 1
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  }
  
})